package com.interview.javabase.algorithm;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * @description:
 * @author: zhangshuguang@vichain.com
 * @date: 2019/06/12 15:19
 */
@SpringBootTest
public class Demo11 {

    @Test
    public void solution1() {
        LinkedNode linkedNode1 = new LinkedNode(1);
        LinkedNode linkedNode2 = new LinkedNode(2);
        LinkedNode linkedNode3 = new LinkedNode(3);

        linkedNode1.next = linkedNode2;
        linkedNode2.next = linkedNode3;

        print(linkedNode1);

    }

    private void print(LinkedNode head) {

        if (head == null) {
            return;
        }
        print(head.next);
        System.out.println(head.val);
    }

}
